package com.ce.socket;

import java.util.HashMap;
import java.util.Map;

import com.ce.study.socketpool.CM20JAVA;

public class SendRunnable implements Runnable {
	private DalSocketPool pool;
	private Map<String,String> mbody = new HashMap<String, String>();
	private byte[] msg;
	
	public SendRunnable(DalSocketPool pool) throws Exception {
		this.pool = pool;
		mbody.put("URI", "/dal/testnoauth/fcode.xml");
		mbody.put("METHOD", "GET");
		CM20JAVA reqmsg = new CM20JAVA(mbody);
		reqmsg.encode();
		msg = reqmsg.getMessage();
	}

	public void run() {
		for (int i = 0; i < 100; i++) {
			try {
				byte[] rep = pool.sendData(msg, 3);
				CM20JAVA repmsg = new CM20JAVA(Map.class);
				repmsg.decode(rep);
				Object repObj = repmsg.getBodyObject();
				//System.out.println(repObj);
				Thread.sleep(100);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

}
